Adding trace propagation to local observations#1724
Conversation
fd33547 to
dac5d5b
Compare
405f59f to
7b02aa2
Compare
Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io>
…ing-boot-observation module Eliminates the verbatim duplication between dapr-spring-boot-autoconfigure (Spring Boot 3.x) and dapr-spring-boot-4-autoconfigure (Spring Boot 4.x): both modules previously held 100%-identical copies of ObservationDaprClient (~820 LOC) and ObservationDaprWorkflowClient (~400 LOC, including the W3C traceparent/tracestate formatters, repeated 4 times overall). Introduces a new Spring-agnostic module dapr-spring/dapr-spring-boot-observation under package io.dapr.spring.observation.client holding a single canonical copy of both decorators plus a package-private TraceContextFormat helper that replaces the 4 duplicated formatter copies. The module has zero Spring imports so it can be shared safely across Spring Boot 3.x and 4.x without API drift. Autoconfigure modules now depend on dapr-spring-boot-observation (optional), replacing their direct opentelemetry-api dependency. Consumers who skip observation wiring still don't pull OTel onto the classpath. OtelTracingClientInterceptor is now a private static final singleton on ObservationDaprWorkflowClient instead of allocated per client — justified by its existing javadoc which already stated it is stateless and shareable. Tests for the decorators themselves moved to the new module (33 pass); the Spring-wiring test DaprClientObservationAutoConfigurationTest stays in boot 3 with updated imports. Net: -1104 lines. Signed-off-by: Javier Aliaga <javier@diagrid.io>
…nfigure poms The autoconfigure classes directly reference ObservationDaprClient and ObservationDaprWorkflowClient in their bean factory methods. When the observation module was marked <optional>, it was not propagated through the starters, causing a potential NoClassDefFoundError at runtime for users with a non-noop ObservationRegistry (e.g. actuator + tracing). Removing <optional> restores the original behavior: the Observation decorator classes are always on the classpath wherever the autoconfig is loaded. Signed-off-by: Javier Aliaga <javier@diagrid.io>
5772cd1 to
6b64ecc
Compare
|
/LGTM accepting this PR low code cov because some methods are not covered on purpose. |
* adding trace propagation to local observations Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> * refactor(spring): extract Observation decorators into shared dapr-spring-boot-observation module Eliminates the verbatim duplication between dapr-spring-boot-autoconfigure (Spring Boot 3.x) and dapr-spring-boot-4-autoconfigure (Spring Boot 4.x): both modules previously held 100%-identical copies of ObservationDaprClient (~820 LOC) and ObservationDaprWorkflowClient (~400 LOC, including the W3C traceparent/tracestate formatters, repeated 4 times overall). Introduces a new Spring-agnostic module dapr-spring/dapr-spring-boot-observation under package io.dapr.spring.observation.client holding a single canonical copy of both decorators plus a package-private TraceContextFormat helper that replaces the 4 duplicated formatter copies. The module has zero Spring imports so it can be shared safely across Spring Boot 3.x and 4.x without API drift. Autoconfigure modules now depend on dapr-spring-boot-observation (optional), replacing their direct opentelemetry-api dependency. Consumers who skip observation wiring still don't pull OTel onto the classpath. OtelTracingClientInterceptor is now a private static final singleton on ObservationDaprWorkflowClient instead of allocated per client — justified by its existing javadoc which already stated it is stateless and shareable. Tests for the decorators themselves moved to the new module (33 pass); the Spring-wiring test DaprClientObservationAutoConfigurationTest stays in boot 3 with updated imports. Net: -1104 lines. Signed-off-by: Javier Aliaga <javier@diagrid.io> * fix(spring): make dapr-spring-boot-observation non-optional in autoconfigure poms The autoconfigure classes directly reference ObservationDaprClient and ObservationDaprWorkflowClient in their bean factory methods. When the observation module was marked <optional>, it was not propagated through the starters, causing a potential NoClassDefFoundError at runtime for users with a non-noop ObservationRegistry (e.g. actuator + tracing). Removing <optional> restores the original behavior: the Observation decorator classes are always on the classpath wherever the autoconfig is loaded. Signed-off-by: Javier Aliaga <javier@diagrid.io> --------- Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Javier Aliaga <javier@diagrid.io> (cherry picked from commit 54833d7)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1724 +/- ##
============================================
+ Coverage 72.90% 76.76% +3.85%
- Complexity 2257 2260 +3
============================================
Files 242 241 -1
Lines 7415 7066 -349
Branches 738 740 +2
============================================
+ Hits 5406 5424 +18
+ Misses 1648 1279 -369
- Partials 361 363 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* adding trace propagation to local observations Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> * refactor(spring): extract Observation decorators into shared dapr-spring-boot-observation module Eliminates the verbatim duplication between dapr-spring-boot-autoconfigure (Spring Boot 3.x) and dapr-spring-boot-4-autoconfigure (Spring Boot 4.x): both modules previously held 100%-identical copies of ObservationDaprClient (~820 LOC) and ObservationDaprWorkflowClient (~400 LOC, including the W3C traceparent/tracestate formatters, repeated 4 times overall). Introduces a new Spring-agnostic module dapr-spring/dapr-spring-boot-observation under package io.dapr.spring.observation.client holding a single canonical copy of both decorators plus a package-private TraceContextFormat helper that replaces the 4 duplicated formatter copies. The module has zero Spring imports so it can be shared safely across Spring Boot 3.x and 4.x without API drift. Autoconfigure modules now depend on dapr-spring-boot-observation (optional), replacing their direct opentelemetry-api dependency. Consumers who skip observation wiring still don't pull OTel onto the classpath. OtelTracingClientInterceptor is now a private static final singleton on ObservationDaprWorkflowClient instead of allocated per client — justified by its existing javadoc which already stated it is stateless and shareable. Tests for the decorators themselves moved to the new module (33 pass); the Spring-wiring test DaprClientObservationAutoConfigurationTest stays in boot 3 with updated imports. Net: -1104 lines. Signed-off-by: Javier Aliaga <javier@diagrid.io> * fix(spring): make dapr-spring-boot-observation non-optional in autoconfigure poms The autoconfigure classes directly reference ObservationDaprClient and ObservationDaprWorkflowClient in their bean factory methods. When the observation module was marked <optional>, it was not propagated through the starters, causing a potential NoClassDefFoundError at runtime for users with a non-noop ObservationRegistry (e.g. actuator + tracing). Removing <optional> restores the original behavior: the Observation decorator classes are always on the classpath wherever the autoconfig is loaded. Signed-off-by: Javier Aliaga <javier@diagrid.io> --------- Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Javier Aliaga <javier@diagrid.io>
* adding trace propagation to local observations Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> * refactor(spring): extract Observation decorators into shared dapr-spring-boot-observation module Eliminates the verbatim duplication between dapr-spring-boot-autoconfigure (Spring Boot 3.x) and dapr-spring-boot-4-autoconfigure (Spring Boot 4.x): both modules previously held 100%-identical copies of ObservationDaprClient (~820 LOC) and ObservationDaprWorkflowClient (~400 LOC, including the W3C traceparent/tracestate formatters, repeated 4 times overall). Introduces a new Spring-agnostic module dapr-spring/dapr-spring-boot-observation under package io.dapr.spring.observation.client holding a single canonical copy of both decorators plus a package-private TraceContextFormat helper that replaces the 4 duplicated formatter copies. The module has zero Spring imports so it can be shared safely across Spring Boot 3.x and 4.x without API drift. Autoconfigure modules now depend on dapr-spring-boot-observation (optional), replacing their direct opentelemetry-api dependency. Consumers who skip observation wiring still don't pull OTel onto the classpath. OtelTracingClientInterceptor is now a private static final singleton on ObservationDaprWorkflowClient instead of allocated per client — justified by its existing javadoc which already stated it is stateless and shareable. Tests for the decorators themselves moved to the new module (33 pass); the Spring-wiring test DaprClientObservationAutoConfigurationTest stays in boot 3 with updated imports. Net: -1104 lines. Signed-off-by: Javier Aliaga <javier@diagrid.io> * fix(spring): make dapr-spring-boot-observation non-optional in autoconfigure poms The autoconfigure classes directly reference ObservationDaprClient and ObservationDaprWorkflowClient in their bean factory methods. When the observation module was marked <optional>, it was not propagated through the starters, causing a potential NoClassDefFoundError at runtime for users with a non-noop ObservationRegistry (e.g. actuator + tracing). Removing <optional> restores the original behavior: the Observation decorator classes are always on the classpath wherever the autoconfig is loaded. Signed-off-by: Javier Aliaga <javier@diagrid.io> --------- Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
|
@holopin-bot @salaboy sdk-badge Thank you! Here's a digital badge as a small token of appreciation. |
|
Congratulations @salaboy, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmqbfcwl00013ks0bd8spsq85 This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
Description
Unfortunately, without adding trace propagation to the observations created in the SDK, traces are not correlated automatically.
With this PR, traces are correlated

WIthout this PR, we have a span, but that span is not correlated with downstream spans
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #1725
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: